package com.unknowpupil.sell.config.wx;
import com.lly835.bestpay.config.WxPayConfig;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Classname: WechatPayConfig
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2020/1/1 16:40
 * @Description:
 * @Version: 1.0
 */
@Component
public class WechatPayConfig {
    @Autowired
    private WxMpProperties wxMpProperties;

    @Bean
    public BestPayServiceImpl bestPayService() {
        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        bestPayService.setWxPayConfig(wxPayConfig());
        return bestPayService;
    }

    @Bean
    public WxPayConfig wxPayConfig() {
        WxPayConfig wxPayConfig = new WxPayConfig();
        wxPayConfig.setAppId(wxMpProperties.getAppId());
        wxPayConfig.setAppSecret(wxMpProperties.getSecret());
        wxPayConfig.setMchId(wxMpProperties.getMchId());
        wxPayConfig.setMchKey(wxMpProperties.getMchKey());
        wxPayConfig.setKeyPath(wxMpProperties.getKeyPath());
        wxPayConfig.setNotifyUrl(wxMpProperties.getNotifyUrl());
        return wxPayConfig;
    }
}
